package com.myway.dto.currencyrate.domain;

import java.util.HashMap;

/****
 * 币种
 * CNY人民币、USD美元、EUR欧元、HKD港币、GBP英镑、JPY日元、KRW韩元、CAD加元、AUD澳元、
 * MNT蒙图、CHF瑞郎、SGD新加坡元、MYR马来西亚币、IDR印尼盾、NZD新西兰元、VND越南盾、THB泰铢
 *
 */
public enum Currency {
	
	CNY("CNY"),
	USD("USD"),
	HKD("HKD"),
	EUR("EUR"),
	GBP("GBP"),
	JPY("JPY"),
	KRW("KRW"),
	CAD("CAD"),
	AUD("AUD"),
	MNT("MNT"),
	CHF("CHF"),
	SGD("SGD"),
	MYR("MYR"),
	IDR("IDR"),
	NZD("NZD"),
	VND("VND"),
	THB("THB");
	
	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the action enum with alias name as key.
	 */
	private static HashMap<String, Currency> map;
	
	private static HashMap<String, String> map1;

	/**
	 * Construct the hash map at load time
	 */
	static 
	{
		map = new HashMap<String, Currency>();
		for (Currency type : Currency.values()) {
			map.put(type.alias, type);
		}
		
		map1 = new HashMap<String, String>();
		map1.put("CNY", "人民币");
		map1.put("USD", "美元");
		map1.put("HKD", "港元");
		map1.put("TUG", "蒙图");
		map1.put("EUR", "欧元");
		map1.put("GBP", "英镑");
		map1.put("JPY", "日元");
		map1.put("KRW", "韩元");
		map1.put("CAD", "加元");
		map1.put("AUD", "澳元");
		
		
	}

	Currency(String alias) 
	{
		this.alias = alias;
	}

	@Override
	public String toString()
	{
		return this.alias;

	}

	/**
	 * Return a <code>Action</code> object holding the value of specified alias name
	 *
	 * @param alias
	 *            the alias name of the type
	 *
	 * @return a <code>Action</code> object holding the value represented by the alias name
	 *         argument
	 */
	public static Currency valueOfAlias(String alias)
	{
		Currency type = map.get(alias);

		if (type == null) {
			throw new IllegalArgumentException("Unknown action alias [" + alias + "]");
		}

		return type;
	}

	/**
	 * @return the alias
	 */
	public String getAlias() {
		return this.alias;
	}
	
	
	
	public static HashMap<String, String> getMap1() {
		return map1;
	}

	public static void setMap1(HashMap<String, String> map1) {
		Currency.map1 = map1;
	}

}
